<template>
	<view class="appBox">
		<view class="list-card">
			<block v-for="(item,index) in listMenu" :key="index">
				<navigator class="list-item" hover-class="none" :url="item.url">
					<view class="left">
						<view class="txt">{{item.title}}</view>
					</view>
					<image class="right" src="/static/images/right.png" mode="">
				</navigator>
			</block>
			
			<block>
				<view class="list-item" @click="clearCache">
					<view class="left">
						<view class="txt">清除缓存</view>
					</view>
					<image class="right" src="/static/images/right.png" mode="">
				</view>
			</block>
			 
		</view>
		<button class="btn" @click="exitLogin">退出登录</button>
		
			<!-- #ifdef APP-PLUS -->
		<view style="display: flex;justify-content: center;margin-top: 30px;">
			<text>{{version}}</text>
		</view>
		<!-- #endif -->
		
		
		
	</view>
</template>

<script>
	import {
		getLogout
	} from "@/api/user";
	import {
		toLogin
	} from '@/libs/login.js';
	export default {
		name: 'login_mobile',
		data() {
			return {
				listMenu: [{
						title: '收货地址',
						url: '/pages/users/user_address_list/index',
					},
					{
						title: '实名认证',
						url: '/pages/settings/realNameAuth/index',
					},
					{
						title: '银行卡列表',
						url: '/pages/blankList/blankList',
					},
					{
						title: '修改密码',
						url: '/pages/users/user_pwd_edit/index',
					},
					{
						title: '交易密码',
						url: '/pages/settings/tradePassword/index',
					},
					{
						title: '关于我们',
						url: '/pages/settings/about_us/index',
					},
					
					// {
					// 	title: '清除缓存',
					// 	// url: '/pages/settings/tradePassword/index',
					// },
				],
             version:"1.0.1"

			}
		},
		components: {},
		mounted() {
			let that = this;
				// #ifdef APP-PLUS 
			plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
				 that.version = wgtinfo.version
			});
			// #endif
			
			//this.getCode();
		},
		onLoad: function(options) {
			let that = this;
			// 获取系统信息
			uni.getSystemInfo({
				success(res) {
					that.platform = res.platform;
				}
			});
			const {
				code,
				state,
				scope,
				back_url,
				appleShow
			} = options;
			that.options = options
			if (options.authKey) that.authKey = options.authKey
			if (options.appleShow) that.appleShow = options.appleShow
		},
		methods: {
			async exitLogin() {

				uni.showLoading({
					title: '正在加载'
				})
				getLogout().then((res) => {
					this.$util.Tips({
						title: res.message
					});
				     this.quitLogin()
					uni.hideLoading()
				}).catch((res) => { 
					uni.clearStorageSync();
					this.quitLogin()
					uni.hideLoading()
				})
			},
			quitLogin(){
				uni.reLaunch({
					url:"/pages/users/login/index"
				}) 
			},
			clearCache(){
				let storageInfo = uni.getStorageInfoSync();
				let size = storageInfo.currentSize;
				
				uni.showLoading({
					title:"正在清除缓存"
				});
				
				uni.clearStorageSync();
				uni.hideLoading();
				uni.showToast({
					title:"缓存已清除",
					icon:"success"
				})
			}
		}
	}
</script>

<style>
	page {
		height: 100%;
	}
</style>
<style lang="scss" scoped>
	@import url("../../../static/css/gstyle.scss");

	.appBox {
		background-color: #F5F6F7;
		height: 100%;
		padding: 33rpx 33rpx 16rpx 33rpx;

		.list-card {

			.list-item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				height: 90rpx;
				background: #fff;
				margin-top: 20rpx;
				padding: 21rpx 27rpx;
				font-family: PingFang SC;
				font-weight: 400;
				font-size: 34rpx;
				color: #333333;

				.right {
					height: 31rpx;
					width: 17rpx;
				}
			}
		}
	}

	page {
		background-color: #fff !important;
	}
</style>
